home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 15
/
Aminet 15 - Nov 1996.iso
/
Aminet
/
dev
/
basic
/
ace24dist.lha
/
ace24.lha
/
prgs
/
Speech
/
SpeechTool.b
< prev
next >
Wrap
Text File
|
1996-09-10
|
8KB
|
281 lines
{*
** ACE Speech Tool.
**
** Initial requester code generated by ReqEd. Code rearranged
** and more comments added for better readability. Redundant
** (naive) code also removed.
**
** Author: David J Benn
** Date: 31st January, 1st,2nd February 1995
*}
DEFLNG a-z
{*
** Contants.
*}
CONST true = -1&
CONST false = 0&
CONST null = 0&
{*
** Variables.
*}
DIM SHORTINT theVoice(8)
STRING phonemeString, textString
{*
** Subprograms.
*}
SUB SetDefaultParams
SHARED theVoice
RESTORE
FOR i=0 TO 8 : READ theVoice(i) : NEXT
DATA 110,0,150,0,22200,64,10,0,0
END SUB
SUB ChangeParamGadgets
SHARED theVoice
'..Voice parameter sliders and longint gadgets.
GADGET MOD 244,theVoice(0) - 65 : GADGET CLOSE 245
GADGET 245,ON,MID$(STR$(theVoice(0)),2),(416,5)-(481,17),LONGINT '..pitch
GADGET MOD 246,theVoice(2) - 40 : GADGET CLOSE 247
GADGET 247,ON,MID$(STR$(theVoice(2)),2),(416,22)-(481,34),LONGINT '..rate
GADGET MOD 252,theVoice(4)\1000 - 5 : GADGET CLOSE 250
GADGET 250,ON,MID$(STR$(theVoice(4)),2),(416,39)-(481,51),LONGINT '..tuning
GADGET MOD 251,theVoice(5) : GADGET CLOSE 253
GADGET 253,ON,MID$(STR$(theVoice(5)),2),(416,56)-(481,68),LONGINT '..volume
GADGET MOD 255,theVoice(6) : GADGET CLOSE 249
GADGET 249,ON,MID$(STR$(theVoice(6)),2),(416,73)-(481,85),LONGINT '..channel
GADGET MOD 254,theVoice(8) : GADGET CLOSE 248
GADGET 248,ON,MID$(STR$(theVoice(8)),2),(416,90)-(481,102),LONGINT '..control
'..Inflection, Gender and Mode (binary) sliders.
GADGET MOD 235,theVoice(1)
GADGET MOD 236,theVoice(3)
GADGET MOD 237,theVoice(7)
END SUB
SUB ChangeValue(theGadget)
SHARED theVoice, phonemeString, textString
ADDRESS strAddr
CASE
'..pitch
theGadget = 245 : theVoice(0) = GADGET(2)
theGadget = 244 : theVoice(0) = GADGET(3) + 65
'..rate
theGadget = 247 : theVoice(2) = GADGET(2)
theGadget = 246 : theVoice(2) = GADGET(3) + 40
'..tuning
theGadget = 250 : theVoice(4) = GADGET(2)
theGadget = 252 : theVoice(4) = GADGET(3)*1000 + 5000 '..convert to KHz.
'..volume
theGadget = 253 : theVoice(5) = GADGET(2)
theGadget = 251 : theVoice(5) = GADGET(3)
'..channel
theGadget = 249 : theVoice(6) = GADGET(2)
theGadget = 255 : theVoice(6) = GADGET(3)
'..control
theGadget = 248 : theVoice(8) = GADGET(2)
theGadget = 254 : theVoice(8) = GADGET(3)
'..inflection
theGadget = 235 : theVoice(1) = GADGET(3) : IF theVoice(1) > 1 THEN theVoice(1) = 1
'..gender
theGadget = 236 : theVoice(3) = GADGET(3) : IF theVoice(3) > 1 THEN theVoice(3) = 1
'..mode
theGadget = 237 : theVoice(7) = GADGET(3) : IF theVoice(7) > 1 THEN theVoice(7) = 1
'..text input
theGadget = 242 : strAddr = GADGET(2) : IF strAddr <> null THEN
textString = CSTR(strAddr)
SAY TRANSLATE$(textString),theVoice
END IF
'..phoneme input
theGadget = 243 : strAddr = GADGET(2) : IF strAddr <> null THEN
phonemeString = UCASE$(CSTR(strAddr))
SAY phonemeString,theVoice
END IF
END CASE
END SUB
SUB GadgetAction(theGadget)
SHARED textString, theVoice
CASE
'..pitch
theGadget = 245 : GADGET MOD 244,theVoice(0) - 65
theGadget = 244 : GADGET CLOSE 245 : GADGET 245,ON,MID$(STR$(theVoice(0)),2), ~
(416,5)-(481,17),LONGINT
'..rate
theGadget = 247 : GADGET MOD 246,theVoice(2) - 40
theGadget = 246 : GADGET CLOSE 247 : GADGET 247,ON,MID$(STR$(theVoice(2)),2), ~
(416,22)-(481,34),LONGINT
'..tuning
theGadget = 250 : GADGET MOD 252,theVoice(4)\1000 - 5
theGadget = 252 : GADGET CLOSE 250 : GADGET 250,ON,MID$(STR$(theVoice(4)),2), ~
(416,39)-(481,51),LONGINT
'..volume
theGadget = 253 : GADGET MOD 251,theVoice(5)
theGadget = 251 : GADGET CLOSE 253 : GADGET 253,ON,MID$(STR$(theVoice(5)),2), ~
(416,56)-(481,68),LONGINT
'..channel
theGadget = 249 : GADGET MOD 255,theVoice(6)
theGadget = 255 : GADGET CLOSE 249 : GADGET 249,ON,MID$(STR$(theVoice(6)),2), ~
(416,73)-(481,85),LONGINT
'..control
theGadget = 248 : GADGET MOD 254,theVoice(8)
theGadget = 254 : GADGET CLOSE 248 : GADGET 248,ON,MID$(STR$(theVoice(8)),2), ~
(416,90)-(481,102),LONGINT
'..inflection
theGadget = 235 : COLOR 3,0:SETXY 543,26:IF theVoice(1)=0 THEN ? "Y"; ELSE ? "N";
'..gender
theGadget = 236 : COLOR 3,0:SETXY 543,62:IF theVoice(3)=0 THEN ? "M"; ELSE ? "F";
'..mode
theGadget = 237 : COLOR 3,0:SETXY 543,98:IF theVoice(7)=0 THEN ? "S"; ELSE ? "A";
'..Show Phonemes
theGadget = 241 : IF textString <> "" THEN MsgBox TRANSLATE$(textString),"Continue"
'..Reset Parameters
theGadget = 240 : SetDefaultParams : ChangeParamGadgets
'..About
theGadget = 239 : MsgBox "Version 1.0, by David J Benn","Continue"
END CASE
END SUB
SUB SpeechTool
SHARED theVoice
SHORTINT theGadget, n
WINDOW 9,"ACE Speech Tool",(22,23)-(612,237),14
FONT "topaz.font",8
PENUP
'..Voice parameter sliders and longint gadgets.
COLOR 2,0
SETXY 40,12
PRINT "Pitch";
GADGET 244,ON,255,(90,3)-(400,13),POTX : GADGET MOD 244,theVoice(0) - 65
GADGET 245,ON,MID$(STR$(theVoice(0)),2),(416,5)-(481,17),LONGINT '..pitch
'SETXY 416,11 : PRINT theVoice(0);
COLOR 2,0
SETXY 48,29
PRINT "Rate";
GADGET 246,ON,360,(90,20)-(401,30),POTX : GADGET MOD 246,theVoice(2) - 40
GADGET 247,ON,MID$(STR$(theVoice(2)),2),(416,22)-(481,34),LONGINT '..rate
'SETXY 416,28 : PRINT theVoice(2);
COLOR 2,0
SETXY 32,46
PRINT "Tuning";
GADGET 252,ON,23,(90,37)-(400,47),POTX : GADGET MOD 252,theVoice(4)\1000 - 5
GADGET 250,ON,MID$(STR$(theVoice(4)),2),(416,39)-(481,51),LONGINT '..tuning
'SETXY 416,45 : PRINT theVoice(4);
COLOR 2,0
SETXY 32,63
PRINT "Volume";
GADGET 251,ON,64,(90,54)-(400,64),POTX : GADGET MOD 251,theVoice(5)
GADGET 253,ON,MID$(STR$(theVoice(5)),2),(416,56)-(481,68),LONGINT '..volume
'SETXY 416,62 : PRINT theVoice(5);
COLOR 2,0
SETXY 24,80
PRINT "Channel";
GADGET 255,ON,11,(90,71)-(400,81),POTX : GADGET MOD 255,theVoice(6)
GADGET 249,ON,MID$(STR$(theVoice(6)),2),(416,73)-(481,85),LONGINT '..channel
'SETXY 416,79 : PRINT theVoice(6);
COLOR 2,0
SETXY 24,97
PRINT "Control";
GADGET 254,ON,2,(90,88)-(400,98),POTX : GADGET MOD 254,theVoice(8)
GADGET 248,ON,MID$(STR$(theVoice(8)),2),(416,90)-(481,102),LONGINT '..control
'SETXY 416,96 : PRINT theVoice(8);
'..Inflection, Gender and Mode (binary) sliders.
COLOR 2,0
SETXY 490,12
PRINT "Inflection";
COLOR 3,0
SETXY 543,26
PRINT "Y";
GADGET 235,ON,2,(523,15)-(538,30),POTY
COLOR 2,0
SETXY 506,48
PRINT "Gender";
COLOR 3,0
SETXY 543,62
PRINT "M";
GADGET 236,ON,2,(523,51)-(538,66),POTY
COLOR 2,0
SETXY 514,84
PRINT "Mode";
COLOR 3,0
SETXY 543,98
PRINT "S";
GADGET 237,ON,2,(523,87)-(538,102),POTY
'..Phoneme and text input gadgets.
COLOR 2,0
SETXY 11,120
PRINT "Phonemes";
GADGET 243,ON,"",(16,126)-(576,139),STRING
COLOR 2,0
SETXY 11,156
PRINT "Text";
GADGET 242,ON,"",(16,162)-(576,175),STRING
'..Buttons.
GADGET 241,ON,"Show Phonemes",(10,180)-(132,196),BUTTON
GADGET 240,ON,"Reset Parameters",(182,180)-(331,196),BUTTON
GADGET 239,ON,"About...",(381,180)-(464,196),BUTTON
GADGET 238,ON,"Quit",(515,180)-(571,196),BUTTON
'..Loop until 'Quit' button or close-gadget clicked.
finished = false
REPEAT
GADGET WAIT 0
theGadget = GADGET(1)
IF theGadget = 238 OR theGadget = 256 THEN
finished = true
ELSE
ChangeValue(theGadget)
GadgetAction(theGadget)
END IF
UNTIL finished
{* CLEAN UP *}
FOR n=255 TO 235 STEP -1
GADGET CLOSE n
NEXT
WINDOW CLOSE 9
END SUB
{*
** Main.
*}
SetDefaultParams
SpeechTool
END